//
//  ImageGrabTableViewCell.m
//  CloudMD
//
//  Created by apple on 16/2/22.
//  Copyright (c) 2016年 HuaZhengInfo. All rights reserved.
//

#import "ImageGrabTableViewCell.h"

@implementation ImageGrabTableViewCell

//- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
//
//    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
//        
//        [_imageArray removeAllObjects];
//        _imageArray = [[NSUserDefaults standardUserDefaults] objectForKey:@"IMAGE"];
//        
//        [self buildUI];
//    }
//    return self;
//}


//- (void)setImageArray:(NSMutableArray *)imageArray{

//    _imageArray = imageArray;

//}

- (void)setImageArray:(NSMutableArray *)imageArray{
    if (!self.label) {
        self.label = [GDFactory creatUILabelWithFrame:CGRectMake(10, 15, self.frame.size.width, self.frame.size.height * 0.2) text:@"资料:" textColor:RED textFont:[UIFont systemFontOfSize:16]];
        [self.contentView addSubview:self.label];
    }
    
    CGFloat margin = 5;
    CGFloat startX = 10;
    CGFloat imageW = SCR_W / 6;
    CGFloat imageH = imageW;
    
    if (imageArray.count > 0) {
        
       for (int i = 0; i < imageArray.count; i ++) {
        
        _infoImage = [[UIImageView alloc] initWithFrame:CGRectMake(startX + (imageW + margin) * i, CGRectGetMaxY(self.label.frame) + 10, imageW, imageH)];
        NSString * str = imageArray[i];
        NSURL * url = [NSURL URLWithString:str];
        [_infoImage setImageWithURL:url placeholderImage:[UIImage imageNamed:@"placeholder (1)"]];
        
//        _infoImage.image = [UIImage imageNamed:[NSString stringWithFormat:@"%@",_imageArray[i]]];
//        _infoImage.backgroundColor = [UIColor redColor];
        [self.contentView addSubview:_infoImage];
      }
    }else{
    
        _imageArray = [NSMutableArray arrayWithObjects:@"nopic", nil];
        _infoImage = [[UIImageView alloc] initWithFrame:CGRectMake(startX, CGRectGetMaxY(self.label.frame) + 10, imageW, imageH)];
        NSString * imageName = [_imageArray firstObject];
        [_infoImage setImage:[UIImage imageNamed:imageName]];
        [self.contentView addSubview:_infoImage];
    }
    
    
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
